﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace DataShow.work
{
    /// <summary>
    /// HandleFile 的摘要说明
    /// </summary>
    public class HandleFile : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            HttpPostedFile file = context.Request.Files["FileData"];
            if (file != null)
            {
                byte[] contentByte = new byte[file.ContentLength];
                file.InputStream.Read(contentByte, 0, file.ContentLength);
                string content = Encoding.ASCII.GetString(contentByte);
                if (string.IsNullOrEmpty(content))
                {
                    context.Response.Write("文件没有内容");
                    context.Response.End();
                }
                bool suc = new codeBLL.WorkBLL().AnalyseTXT(content);
                if (suc == true)
                {
                    context.Response.Write("1");
                }
                else
                {
                    context.Response.Write("导入前"+context.Session["sheetcount"]+"条数据");
                }
            }
            else
            {
                context.Response.Write("0");
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}